"""
@author: xxw
@file: 2023-04-13-面向对象-ATM.py
@time: 2023/4/13 14:53
"""

# atm类
#ATM类 -- 哪些类属性，哪些实例属性，哪些方法
# 类属性  -- country
# 实例属性  -- bank,area
# 方法  -- 存钱，取钱，查询

# 用户类
# 类属性 --
# 实例属性 -- 余额，用户名，密码

class ATM:
    country = "china"

    def __init__(self, bank, area, money):
        self.bank = bank
        self.area = area
        self.money = money

    def store_money(self, money, user):
        self.money += money
        user.balance += money
        print(f"存款成功！{user.name}账户余额为：{user.balance}元")

    def withdrawal(self, money, user):
        if self.money < money:
            print("该取款机余额不足")
        elif user.balance <= 0:
            print("你账户余额不足")
        else:
            self.money -= money
            user.balance -= money
            print(f"存款成功！{user.name}账户余额为：{user.balance}元")



class User:
    def __init__(self, name, passwd, balance):
        self.name = name
        self.passwd = passwd
        self.balance = balance

atm1 = ATM("农行","东湖小区",50000)
user1 = User("xxw", "123456", 2000000)
atm1.store_money(100000, user1)
atm1.withdrawal(20000, user1)

